package cn.itsource.order.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.order.domain.ProductDetail;
import cn.itsource.order.service.IProductDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/productDetail")
public class ProductDetailController {

    @Autowired
    private IProductDetailService productDetailService;

    /**
     * 查询所有
     */
    @GetMapping
    public AjaxResult queryAll() {
        List<ProductDetail> list = productDetailService.queryAll();
        return AjaxResult.ok(list);
    }

    /**
     * 保存数据
     */
    @PostMapping("/save")
    public AjaxResult save(@RequestBody ProductDetail productDetail) {
        boolean result = productDetailService.save(productDetail);
        return AjaxResult.toAjax(result);
    }


    /**
     * 删除操作
     */
    @DeleteMapping("{id}")
    public AjaxResult delete(@PathVariable Long id) {
        boolean result = productDetailService.delete(id);
        return AjaxResult.toAjax(result);
    }

}
